package com.qf.j2112.service.impl;

import com.github.pagehelper.PageHelper;
import com.qf.j2112.mapper.TourAreaMapper;
import com.qf.j2112.po.TourArea;
import com.qf.j2112.service.TourAreaService;
import com.qf.j2112.utils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TourAreaServiceImpl implements TourAreaService {

    @Resource
    private TourAreaMapper tourAreaMapper;

    @Override
    public int countArea() {
        return tourAreaMapper.countArea();
    }

    @Override
    public List<TourArea> findAll(PageUtil pageUtil) {
        PageHelper.startPage(pageUtil.getPage(),pageUtil.getPageSize());
        return tourAreaMapper.findAll();
    }

    @Override
    public List<TourArea> findUsefulTourArea() {
        return tourAreaMapper.findUsefulTourArea();
    }

    @Override
    public TourArea findOneByAid(int aid) {
        return tourAreaMapper.findOneByAid(aid);
    }

    @Override
    public TourArea addTourArea(TourArea area) {
        tourAreaMapper.addTourArea(area);
        return  area;
    }

    @Override
    public boolean deleteTourArea(int aid) {
        int i=tourAreaMapper.delTourArea(aid);
        if(i>-1){
            return  true;
        }
        return false;
    }

    @Override
    public boolean updateTourArea(TourArea area) {
        int i=tourAreaMapper.updateTourArea(area);
        if(i>-1){
            return  true;
        }
        return false;
    }

    @Override
    public boolean banTourArea(int aid, String status) {
        int i=tourAreaMapper.banTourArea(aid,status);
        if(i>-1){
            return  true;
        }
        return false;
    }
}
